package bishi.kedaxunfei;

import java.util.Scanner;

/**
 * @Classname Main2
 * @Description TODO
 * @Date 2021/10/10 20:13
 * @Created by ASUS
 */
public class Main2 {


    public static char[][] getMaze() {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int m = Integer.parseInt(s[0]), n = Integer.parseInt(s[1]);
        char[][] maze = new char[m][n];
        String str;
        for (int i = 0; i < m; i++) {
            str = scanner.nextLine();
            for (int j = 0; j < n; j++) {
                maze[i][j] = str.charAt(j);
            }
        }
        scanner.close();
        return maze;
    }

    static int[][] dirs = new int[][]{{-1, 0}, {0, -1}};

    public static void main(String[] args) {
        char[][] maze = getMaze();
        int m = maze.length, n = maze[0].length;
        int[][] dp = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = Integer.MAX_VALUE;
            }
        }
        dp[0][0] = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0) break;
                int min = Integer.MAX_VALUE;
                for (int[] dir : dirs) {
                    int x = dir[0] + i, y = dir[1] + j;
                    if (x < 0 || x == m || y < 0 || y == n) continue;
                    min = Math.min(min, dp[x][y]);
                }
                dp[i][j] = min + (maze[i][j] == '#' ? 1 : 0);
            }
        }
        System.out.println(dp[m - 1][n - 1]);
    }

}
